<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/commons/taglibs.jsp"%>
<%@ include file="/static/commons/meta.jsp"%>
<%@ include file="/static/commons/jquery-easyui.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>${title }</title>
	<!--自定义index样式-->
	<link rel="stylesheet" href="${ctx }/static/styles/basic/basic.css" ></link>
	<link rel="stylesheet" href="${ctx }/static/styles/edit/tableStyle.css"></link>
	<link rel="stylesheet" href="${ctx }/static/scripts/autocomplete/autocomplate.css" ></link>
	<!--js库-->
	<script type="text/javascript" src="${ctx}/static/scripts/set_select.js"></script>
	<script type="text/javascript" src="${ctx}/static/scripts/check_all.js"></script>
	<style type="text/css">
		.add_icon{background: url(${ctx}/static/images/common/plus_minus.jpg) left 0px no-repeat; width: 14px; height: 15px;cursor: pointer; float: right; margin: 7px 15px 0px 0px; }
		.dev_icon{background: url(${ctx}/static/images/common/plus_minus.jpg) right 0px no-repeat; width: 14px; height: 15px;cursor: pointer; float: right; margin: 7px 15px 0px 0px; display: none; }
		.search_icon{background: url(${ctx}/static/images/head/search.png) no-repeat 1px 50% #c0c0c0;border-radius: 5px;border:1px solid #ccc; width: 20px; height: 20px;cursor: pointer;float:right;margin: 5px 5px 0px 0px}
		.search_icon:HOVER{background-color: #ccc;}
		tr.error{color: red;}
	</style>
	<script type="text/javascript">
        var headers = {};
        headers['__RequestVerificationToken'] = "${RequestVerificationToken}";
	</script>
</head>

<body style="padding:8px;">
<form id="editForm" action="${ctx}/myInspect/save" method="post">
	<input type="hidden" id="equId" name="p_equId" data-field="equ_id" class="echo"></input>
	<input type="hidden" id="orderId" name="p_orderId" data-field="order_id" class="echo"></input>
	<input type="hidden" id="logId" name="p_logId" data-field="log_id" class="echo"></input>
	<input type="hidden" id="recId" name="p_recId" data-field="rec_id" class="echo"></input>
	<input type="hidden" id="originalRecord" name="p_originalRecord" data-field="original_record" class="echo"></input>
	<table id="tag1" class="table-ltr">
		<tbody>
		<tr>
			<td>送检单位：</td>
			<td><vvise:select id="custId" name="p_custId" sqlname="getCust" defval="${obj.custId }" ifSelect="false" /></td>
			<td>检定日期：</td>
			<td>${inspectDate }</td>
			<td class="non-empty">地点：</td>
			<td><input type="text" data-field="address" class="echo" id="address" name="p_address"></input></td>
		</tr>
		<tr>
			<td class="non-empty">仪器编号：</td>
			<td><input type="text" id="deviceNo" name="p_deviceNo" data-field="device_no" class="echo" autocomplete="off" style="width: 115px" placeholder="模糊搜索"></input>
				<div class="search_icon" title="查询"></div></td>
			<td>类型：</td>
			<td <c:if test="${obj.deviceType eq 2}">colspan="3"</c:if>><vvise:select id="deviceType" name="p_deviceType" sqlname="getCodeData" sqlparam="device_type" defval="${obj.deviceType }" ifSelect="false" /></td>
			<c:if test="${obj.deviceType eq 1}">
				<td>容积：</td>
				<td><input type="text" data-field="volume_category_" class="echo" disabled="disabled"></input></td>
			</c:if>
			<c:if test="${obj.deviceType eq 3}">
				<td>气体种类：</td>
				<td><input type="text" data-field="gas_type_" class="echo" id="gasTypeId" name="p_gasType" readonly></input></td>
			</c:if>

			<!-- <td>气体种类：</td>
            <td><input type="text" data-field="gas_type_" class="echo" disabled="disabled"></input></td> -->
		</tr>
		<tr>
			<td>名称：</td>
			<td><input type="text" data-field="device_name" class="echo" disabled="disabled"></input></td>
			<td>生产厂家：</td>
			<td><input type="text" data-field="device_manufactor" class="echo" disabled="disabled"></input></td>
			<c:if test="${obj.deviceType eq 1}">
				<td>出厂日期：</td>
				<td><input type="text" data-field="manufacture_date" class="echo" disabled="disabled"></input></td>
			</c:if>
			<c:if test="${obj.deviceType ne 1}">
				<td>仪器型号：</td>
				<td><input type="text" data-field="device_model" class="echo" disabled="disabled"></input></td>
			</c:if>

			<!-- <td>仪器型号：</td>
            <td><input type="text" data-field="device_model" class="echo" disabled="disabled"></input></td> -->
		</tr>
		<tr>

			<td>检查人员：</td>
			<td>${LoginUser.userName }</td>
			<td class="non-empty">核验人员：</td>
			<td><vvise:select id="checkUser" name="p_checkUser" sqlname="getCheckUser" sqlparam="" className="full_select" /></td>
			<td></td>
			<td></td>
		</tr>
		</tbody>
	</table>

	<table id="tag2"  class="table-ltr" style="white-space: nowrap;">
		<caption>检查明细</caption>

		<tfoot>
		<tr>
			<td class="non-empty">检查人员备注：</td>
			<td colspan="3"><input type="text" data-field="repair_remark" class="echo"  id="repairRemark" name="p_repairRemark"></input></td>
		</tr>
		<tr>
			<td class="non-empty">核验人员备注：</td>
			<td colspan="3"><input type="text" data-field="check_remark" class="echo"   id="checkRemark"  name="p_checkRemark"></input></td>
		</tr>
		</tfoot>
	</table>
</form>
</body>
<script type="text/javascript">
    var resetF, validForm;
    $(function(){
		/* 3. 检索待检设备信息 */
        $(document).delegate('.search_icon', 'click', function(){
            var pp = parent;
            var editFrame = pp.winFrame;
            if(!pp.validData("deviceNo","请输入仪器编号！", 1, editFrame))
                return;

            var deviceNo = editFrame.$('#deviceNo').val();
            var result = pp.executeAjaxBySync('${ctx}/myTesting/getEquipment','p_deviceType=${obj.deviceType}&p_custId=${obj.custId}&p_deviceNo='+deviceNo);
            if(result == 'none'){
                pp.$.messager.alert('操作提示','未查询到待检设备，请重新输入','warning',function(){
                    editFrame.$('#deviceNo').focus();
                });
                return;
            }else{
                var data = eval("("+result+")");
                var equ = data.columns;
                var logId = equ.log_id;
                if(!pp.isEmpty(logId)){
                    pp.$.messager.alert('操作提示','该设备已检测，请重新输入','warning',function(){
                        editFrame.$('#deviceNo').focus();
                    });
                    return;
                }

                $('.echo').each(function(){
                    var field = $(this).data('field');
                    var val = eval('equ.'+field);
                    if(!val){
                        val = ''
                    }
                    $(this).val(val);
                });
                changeSelect('${ctx}/common/getSelectOptions?sqlname=getCheckUser&sqlparam='+equ.equ_id,'checkUser');
                $('#checkUser option').each(function(){
                    if(this.value!='' && this.value!='${LoginUser.userId }'){
                        this.selected = true;
                    }
                });
            }
        });

		/* 4. 表单重置 */
        resetF = function(){
            $('.echo, #address').val('');
            $('#checkUser').find("option:gt(0)").remove();
            $('#tag2').find('input,select').val('');
            $('#tag2 tbody tr:gt(0)').remove();
            $('#tag2 tbody tr .add_icon').show();
            $('#tag2 tbody tr .dev_icon').hide();
        };

		/* 5. 表单非空验证 */
        validForm = function(){
            var pp = parent;
            var editFrame = pp.winFrame;
            if(!pp.validData("address","请输入地点！", 1, editFrame))
                return false;
            if(!pp.validData("deviceNo","请输入仪器编号！", 1, editFrame))
                return false;
            if(!pp.validData("checkUser","请选择核验人员！", 2, editFrame))
                return false;



            if(!pp.validData("repairRemark","请输入维修检测人员备注！", 1, editFrame))
                return false;
            if(!pp.validData("checkRemark","请输入核验人员备注！", 1, editFrame))
                return false;

            return true;
        };

        //自动填充车牌数组
        var result = '${data}';
        var data = jQuery.parseJSON(result);
        $('#deviceNo').autocomplete(data, {
            max: 7, //列表里的条目数
            minChars: 1, //自动完成激活之前填入的最小字符
            width: 150, //提示的宽度，溢出隐藏
            scrollHeight: 180, //提示的高度，溢出显示滚动条
            matchCase: false, //比较是否开启大小写敏感开关
            matchContains: true, //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示
            autoFill: false, //自动填充                  //匹配的项所要发生的事件
            formatItem: function (row, i, max){
                //row表示每一行的数据对象，i表示每一行的编号 max表示总的数据行数
                return row.value + "[" + row.name + "]";
            }
        }).result(function (event, row, formatted) {
            $('#deviceNo').val(row.value);
        });
    });
</script>
<script type="text/javascript" src="${ctx}/static/scripts/autocomplete/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="${ctx}/static/scripts/autocomplete/jquery.autocomplete.js"></script>
</html>